package com.rockcent.mall.lib.domain;

import com.rockcent.common.domain.IDEntityMall;
import com.rockcent.mall.lib.domain.enumclass.TransactionFlow;
import com.rockcent.mall.lib.domain.enumclass.TransactionType;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.*;
import java.math.BigDecimal;

/**
 * 商家交易模型
 */
@Entity
@Table(name = "merchant_transaction")
@DynamicInsert
@DynamicUpdate
public class MerchantTransaction extends IDEntityMall{

    @Column(columnDefinition = "varchar(50) comment '商家订单号'")
    private String merchantOrderNum;
    @Column(columnDefinition = "varchar(50) comment '交易方向 INCOME(\"收入\", \"+\"), EXPEND(\"支出\", \"-\")'")
    @Enumerated(EnumType.STRING)
    private TransactionFlow flow;
    @Column(columnDefinition = "DECIMAL(30,10) comment '实收金额'")
    private BigDecimal amount;
    @Column(columnDefinition = "DECIMAL(30,10) comment '优惠金额'")
    private BigDecimal discount;
    @Column(columnDefinition = "DECIMAL(30,10) comment '源金额'")
    private BigDecimal oriAmount;
    @Column(columnDefinition = "DECIMAL(30,10) comment '余额'")
    private BigDecimal balance;
    @Column(columnDefinition = "varchar(50) comment '交易类型 ORDER_INCOME(\"订单收入\"), MARKET_INCOME(\"自营收入\"), RESELL_INCOME(\"分销收入\"), MERT_RECHARGE(\"商家充值\"), CUST_RECHARGE(\"买家充值\"), MERT_WITHDRAWAL(\"商家提现\"), CUST_WITHDRAWAL(\"买家提现\"), CONFIRM_GOODS(\"确认收货\"), VERIFY_PROD(\"核销产品\")'")
    @Enumerated(EnumType.STRING)
    private TransactionType type;
    @Column(columnDefinition = "varchar(255) comment '交易备注'")
    private String remark;


    public String getMerchantOrderNum() {
        return merchantOrderNum;
    }

    public void setMerchantOrderNum(String merchantOrderNum) {
        this.merchantOrderNum = merchantOrderNum;
    }

    public TransactionFlow getFlow() {
        return flow;
    }

    public void setFlow(TransactionFlow flow) {
        this.flow = flow;
    }

    public BigDecimal getAmount() {
        return amount;
    }

    public void setAmount(BigDecimal amount) {
        this.amount = amount;
    }

    public BigDecimal getDiscount() {
        return discount;
    }

    public void setDiscount(BigDecimal discount) {
        this.discount = discount;
    }

    public BigDecimal getOriAmount() {
        return oriAmount;
    }

    public void setOriAmount(BigDecimal oriAmount) {
        this.oriAmount = oriAmount;
    }

    public BigDecimal getBalance() {
        return balance;
    }

    public void setBalance(BigDecimal balance) {
        this.balance = balance;
    }

    public TransactionType getType() {
        return type;
    }

    public void setType(TransactionType type) {
        this.type = type;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    @Override
    public String toString() {
        return "MerchantTransaction{" +
                "merchantOrderNum='" + merchantOrderNum + '\'' +
                ", id=" + id +
                ", dateCreated=" + dateCreated +
                ", flow=" + flow +
                ", lastUpdated=" + lastUpdated +
                ", amount=" + amount +
                ", discount=" + discount +
                ", isDelete=" + isDelete +
                ", oriAmount=" + oriAmount +
                ", version=" + version +
                ", balance=" + balance +
                ", type=" + type +
                ", remark='" + remark + '\'' +
                '}';
    }
}
